package com.mhkj.base.rbac.role.entity;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import com.mhkj.base.functionOffice.entity.FunctionOffice;
import com.mhkj.base.itemInfo.item.entity.Item;
import com.mhkj.base.rbac.permission.entity.Permission;
import com.mhkj.base.rbac.user.entity.SystemUser;
import com.mics.core.common.validate.annotation.NotNull;
import com.mics.core.common.validate.annotation.Unique;
import com.mics.core.common.validate.annotation.Validate;
import com.mics.core.system.base.entity.BaseDomain;

@Entity
@Table(name = "t_sys_role")
@Validate
public class SystemRole extends BaseDomain {

	/**
	 * 序号
	 */
	private static final long serialVersionUID = -6715557238287573433L;

	/**
	 * 角色名称
	 */
	@Unique(message="角色名称重复")
	@Column(name = "role_name", length = 48)
	@NotNull(message="角色名称不能为空")
	private String roleName;

	/**
	 * 角色表示 admin。。。
	 */
	@Unique(message="角色标识不能重复")
	@Column(name="name",length=48)
	@NotNull(message="角色标识不能为空")
	private String name;
	
	/**
	 * 角色编码
	 */
	@Column(name="code",length=48)
	private String code;
	


	/**
	 * 角色是否可用
	 */
	@Column(name = "available")
	private int available = 0; // 是否可用,如果不可用将不会添加给用户

	// 角色 -- 权限关系：多对多关系;
	 @ManyToMany(fetch=FetchType.LAZY,mappedBy="systemRoles")
	 private List<Permission> permissions;


	/**
	 * 项目
	 */
	@ManyToMany(fetch = FetchType.LAZY,mappedBy="systemRoles")
	private List<Item> items;

	/**
	 * 用户
	 */
	@ManyToMany(fetch = FetchType.LAZY,mappedBy="systemRoles")
	private List<SystemUser> systemUsers;

	/**
	 * 职能
	 */
	@ManyToMany(fetch = FetchType.LAZY,mappedBy="systemRoles")
	private List<FunctionOffice> functions;
	
	public String getRoleName() {
		return roleName;
	}


	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}


	public String getCode() {
		return code;
	}


	public void setCode(String code) {
		this.code = code;
	}


	public int getAvailable() {
		return available;
	}


	public void setAvailable(int available) {
		this.available = available;
	}


	public List<Permission> getPermissions() {
		return permissions;
	}


	public void setPermissions(List<Permission> permissions) {
		this.permissions = permissions;
	}


	public List<Item> getItems() {
		return items;
	}


	public void setItems(List<Item> items) {
		this.items = items;
	}


	public String getName() {
		return name;
	}


	public void setName(String name) {
		this.name = name;
	}


	public List<SystemUser> getSystemUsers() {
		return systemUsers;
	}


	public void setSystemUsers(List<SystemUser> systemUsers) {
		this.systemUsers = systemUsers;
	}


	public List<FunctionOffice> getFunctions() {
		return functions;
	}


	public void setFunctions(List<FunctionOffice> functions) {
		this.functions = functions;
	}
	
}
